<template>
  <div class="container">
    <!-- <img class="logo" :src="imgLogoUrl" /> -->
    <div class="title">齐鲁石化管理平台</div>
    <!-- <div class="slogan"></div> -->
    <div class="main">
      <div class="main-item main-left">
        <img :src="imgLeftUrl" />
      </div>
      <div class="main-item">
        <el-form ref="form" :model="form" :rules="rules">
          <el-form-item prop="username">
            <el-input prefix-icon="el-icon-user" v-model="form.username" placeholder="请输入账户名"></el-input>
          </el-form-item>
          <el-form-item prop="psd">
            <el-input prefix-icon="el-icon-lock" v-model="form.psd" placeholder="请输入密码" show-password></el-input>
          </el-form-item>
          <!-- <el-form-item>
            <el-input prefix-icon="el-icon-user"></el-input>
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary" @click="submitForm('form')">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import imgLogoUrl from "@/assets/images/public/logo@2x.png"
import imgLeftUrl from "@/assets/images/login/left@2x.png"
export default {
  data() {
    return {
      imgLogoUrl,
      imgLeftUrl,
      form: {
        username: "",
        psd: ""
      },
      rules: {
        username: [{ required: true, message: "请输入账户名", trigger: "blur" }],
        psd: [{ required: true, message: "请输入密码", trigger: "blur" }]
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) this.onLogin()
      })
    },
    onLogin() {
      this.$store.dispatch("login/login", this.form).then(res => {
        this.$router.push({ name: "home" })
      })
    }
  }
}
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  background: url("../../assets/images/login/5@2x.png") no-repeat;
  background-size: cover;
  position: relative;
}
.logo {
  position: absolute;
  top: 50px;
  left: 50px;
  width: 190px;
  height: 39px;
}
.title {
  position: absolute;
  top: 140px;
  width: 100%;
  text-align: center;
  font-size: 50px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #ffffff;
}
.slogan {
  position: absolute;
  top: 230px;
  width: 100%;
  text-align: center;
  font-size: 30px;
  font-family: PingFangSC-Semibold, PingFang SC;
  color: #ffffff;
}
.main {
  width: 982px;
  height: 430px;
  border-radius: 16px;
  position: absolute;
  top: 322px;
  display: flex;
  background: #ffffff;
  left: 50%;
  transform: translateX(-50%);
  &-item {
    flex: 1;
    height: 100%;
  }
  &-left img {
    width: 100%;
    height: 100%;
  }
  .el-form {
    margin-top: 50px;
    .el-form-item {
      display: flex;
      justify-content: center;
      // margin-bottom: 30px;
      margin-bottom: 50px;
    }
    /deep/ .el-input {
      width: 370px;
      height: 60px;
      padding-left: 80px;
      font-size: 18px;
      position: relative;
    }
    /deep/ .el-input__inner {
      position: absolute;
      left: 0px;
      width: 100%;
      height: 100%;
      padding-left: 80px;
      border-radius: 30px;
    }
    /deep/ .el-input__prefix {
      width: 80px;
      font-size: 24px;
      text-align: center;
    }
    /deep/ .el-input__suffix {
      width: 80px;
      font-size: 24px;
      text-align: center;
      i {
        font-size: 18px;
      }
    }
    /deep/ .el-form-item__error {
      font-size: 14px;
      margin-left: 50px;
    }
    .el-button {
      width: 260px;
      height: 60px;
      border-radius: 30px;
      font-size: 20px;
      color: #ffffff;
    }
  }
}
</style>
